package com.nuoniu.sibanyun.controller.check;


import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.check.VQualityCheckMain;
import com.nuoniu.sibanyun.service.check.IVQualityCheckMainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.nuoniu.sibanyun.common.BaseController;

/**
 * <p>
 * 质检管理_主表 前端控制器
 * </p>
 *
 * @author 白强
 * @since 2021-07-14
 */
@RestController
@RequestMapping("/qualityCheckMain")
@Api(tags = "质检管理")
public class VQualityCheckMainController extends BaseController {

    @Autowired
    private IVQualityCheckMainService qualityCheckMainService;


    @PostMapping("save")
    @ApiOperation("保存")
    public HttpResult saveQualityCheckMain(@RequestBody VQualityCheckMain qualityCheckMain) {
        qualityCheckMainService.saveQualityCheckMain(qualityCheckMain);
        return HttpResult.ok();
    }

    @GetMapping("getCode")
    @ApiOperation("获取单据编码")
    public HttpResult getCode() {
        return HttpResult.ok( qualityCheckMainService.getCode());
    }

    @ApiOperation("单据提交")
    @GetMapping("submit")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "单据id"),
            @ApiImplicitParam(name = "status", value = "状态 -1:反提交,0:提交")
    })
    public HttpResult submit(Long id, Integer status) {
        qualityCheckMainService.submit(id, status);
        return HttpResult.ok();
    }

    @GetMapping("examine")
    @ApiOperation("审核/弃审")
    public HttpResult examine(Long id, Integer status) {
        qualityCheckMainService.examine(id, status);
        return HttpResult.ok();
    }

    @DeleteMapping("delete")
    @ApiOperation("删除")
    public HttpResult delete(Long id) {
        qualityCheckMainService.delete(id);
        return HttpResult.ok();
    }

}
